
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from '@/router/index'
import pinia from '@/store'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import './styles/common.scss'
import globalError from './error.js'
import loginForm from '@/utils/loginForm'
import userInfo from '@/utils/userInfo'
import openSearch from '@/utils/search'
import openMessage from '@/utils/message'
import fileUpload from '@/utils/fileUpload'
import fileDownload from '@/utils/jvsMessage'
import synchronism from '@/utils/synchronism'
import knowSet from '@/utils/knowSet'
import docSet from '@/utils/docSet'
import dirSet from '@/utils/dirSet'
import templateView from '@/utils/templateView'
import onePrompt from '@/utils/onePrompt'
import { mobileMessage, mobileConfirm, mobileToast } from '@/utils/mobileMessage'
import mixins from '@/utils/mixins.js'
import EventBus from '@/utils/eventBus'

import 'vue3-video-play/dist/style.css'
import commonsUtil from '@/utils/common.js'
import { registerDirectives, directives } from '@/directives'
import { dayjs, dayjsCalendar } from '@/utils/dayjs.js'
import Print from '@/utils/print.js'
import _ from 'lodash'
import indexDB from '@/utils/indexDB.js'
import i18n from '@/lang'
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
const app = createApp(App)
app.use(i18n);
app.use(VueViewer)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 注册自定义指令
registerDirectives(app)
Object.keys(directives).forEach((key) => {
    app.directive(key, directives[key as keyof typeof directives])
})
import { componentPlugin } from '@/components'

app.config.globalProperties.$errorHandler = globalError
app.config.globalProperties.$mobileMessage = mobileMessage.install
app.config.globalProperties.$mobileConfirm = mobileConfirm.install
app.config.globalProperties.$mobileToast = mobileToast.install
app.config.globalProperties.$eventBus = EventBus
app.config.globalProperties.$onePrompt = onePrompt
app.config.globalProperties.$dayjs = dayjs
app.config.globalProperties.$dayjsCalendar = dayjsCalendar
app.config.globalProperties.$indexDB = indexDB
app.config.globalProperties.$lodash = _
app.use(pinia)
import './permission.js'
// import k from './components/mindElixir/MindElixir.js'

// 全局混入
app.mixin(mixins)

app.use(loginForm);
app.use(userInfo)
app.use(openSearch)
app.use(openMessage)
app.use(synchronism)
app.use(fileUpload)
app.use(fileDownload)
app.use(knowSet)
app.use(docSet)
app.use(dirSet)
app.use(templateView)
app.use(Print) // 打印

app.use(commonsUtil);

app.use(componentPlugin)
app.use(router)
app.use(ElementPlus, {
    locale: zhCn,
})
app.mount('#app')

